import logging, os

log_path = os.path.join(os.getcwd(), 'test.log')

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(pathname)s line:%(lineno)d %(message)s ',
                    datefmt='%Y-%m-%d %H:%M:%S',  # 将日期格式化成正常模式
                    filename=log_path,
                    filemode='a')  # 指定成追加模式,默认就是追加，所以这句非必须
